<script setup lang="ts">
import { message } from 'ant-design-vue'
import { addOrUpdate, graphWorkflow } from '~@/api/flow/medatata'

defineOptions({
  name: 'FlowEditor',
})
const route = useRoute()
const graphData = ref()

onMounted(() => {
  if (route.query.name && route.query.version) {
    graphWorkflow(route.query).then((res) => {
      graphData.value = res.data
    })
  }
})

function save(flowData: any) {
  addOrUpdate(flowData).then((res) => {
    message.success(res.msg)
  })
}
</script>

<template>
  <page-container>
    <X6 :graph-data="graphData" @save="save" />
  </page-container>
</template>
